Flatsome theme tutorial on adjusting description length to maximum of 15 words

excerpt lenght

The default description length for list mode in blog posts is 15 words, which may appear too short and unattractive. This guide explains how to change the description length in the Flatsome theme. Access the hosting/VPS file manager and locate the ‘archive-list.php’ file in the Flatsome theme. Copy it to the child theme’s directory, then open the file and add ‘excerpt_length’ => ’40’ after ‘ids’ => $ids. Save the file and review the results. This customization allows for longer descriptions in list mode, improving the appearance of the blog posts.

Thay đổi độ dài mô tả trong theme Flatsome

Thông thường, khi chúng ta sử dụng chế độ list trong danh mục/blog bài viết, độ dài mặc định của phần mô tả là 15 từ, hơi bị ngắn, nhìn không đẹp.

Hôm nay mình hướng dẫn cách thay đổi độ dài mô tả này, trong theme flatsome. Cách làm như sau:

Bước 1: Truy cập vào hosting/vps, mở File Manager lên.

Bước 2: Vào thư mục public_html/wp-content/themes/flatsome/template-parts/post. Sau đó copy file archive-list.php qua child theme của flatsome cũng với đường dẫn public_html/wp-content/themes/flatsome-child/template-parts/post (nếu chưa có thư mục template-parts và post thì các bạn tạo thêm rồi copy qua cho đúng đường dẫn mới có hiệu lực)

Bước 3: Mở file lên, tìm đến đoạn sau:

echo flatsome_apply_shortcode( 'blog_posts', array(
    'type'        => 'row',
    'image_width' => '40',
    'depth'       => get_theme_mod( 'blog_posts_depth', 0 ),
    'depth_hover' => get_theme_mod( 'blog_posts_depth_hover', 0 ),
    'text_align'  => get_theme_mod( 'blog_posts_title_align', 'center' ),
    'style'       => 'vertical',
    'columns'     => '1',
    'show_date'   => get_theme_mod( 'blog_badge', 1 ) ? 'true' : 'false',
    'ids'         => $ids,

) );

Dưới dòng 'ids' => $ids,, bạn thêm 'excerpt_length' => '40', vào. Sau đó lưu lại là được.

See also  Guide on embedding PDF, Excel, Doc files into WordPress websites.

Code sau khi thêm vào:

echo flatsome_apply_shortcode( 'blog_posts', array(
    'type'        => 'row',
    'image_width' => '40',
    'depth'       => get_theme_mod( 'blog_posts_depth', 0 ),
    'depth_hover' => get_theme_mod( 'blog_posts_depth_hover', 0 ),
    'text_align'  => get_theme_mod( 'blog_posts_title_align', 'center' ),
    'style'       => 'vertical',
    'columns'     => '1',
    'show_date'   => get_theme_mod( 'blog_badge', 1 ) ? 'true' : 'false',
    'ids'         => $ids,
    'excerpt_length' => '40',
) );

Note: Bạn đổi số 40 thành số ký tự mình muốn nhé.

Bước 4: Xem kết quả

Sau khi điều chỉnh như trên, mình được kết quả thế này

excerpt lenght

Chúc các bạn thay đổi theo ý mình thành công!

Rate this post

Related posts